CiderRunMode = {};CiderRunMode.runmode = true;CiderRunMode.assertImage = true;require "CiderDebugger";display.setStatusBar(display.HiddenStatusBar)

local physics = require("physics")
physics.start()

--local back = display.newRect(0, 0, 1000, 1000)
--back:setFillColor(165, 210, 255)

-- Load Lime
local lime = require("lime")

-- Load your map
local map = lime.loadMap("level5.tmx")

--player

local playerLib = require("player")


-- Create Player
local onPlayer = function(object)
    local player = playerLib.newPlayer(object.x, object.y)
    map:getTileLayer( "Layer1" ):addObject( player )
    map:setFocus( player )
end
map:addObjectListener("PLAYER", onPlayer)

--baloon
local ballonLib = require("baloon")

-- Create Balloons
local onBalloon = function(object)
    local baloon1 = ballonLib.newBaloon(object.x, object.y)
    map:getTileLayer( "Layer1" ):addObject( baloon1 )
end
map:addObjectListener("BALLOON", onBalloon)

-- Create the visual
local visual = lime.createVisual(map)

-- Build the physical
local physical = lime.buildPhysical(map)

local fcounter = 0
local frame = 0
local textObj = display.newText(fcounter, 50, 0)





local onUpdate = function( event )
-- Update the map. Needed for using map:setFocus()
    map:update( event )
    frame = frame + 1
    if(frame == 30)then
        frame = 0
        fcounter = fcounter + 1
        textObj.text = fcounter
    end
end

Runtime:addEventListener( "enterFrame", onUpdate )


